package com.mt.components.table {
	import com.mt.components.utils.DateUtils;
	
	import mx.controls.dataGridClasses.DataGridColumn;
	
	/**      
	 * 文件名称：DataGridColumnDateTime<br>
	 * 文件描述：<br>
	 * 创建人：马腾<br>
	 * 创建时间：Nov 25, 2012 8:39:41 PM<br>
	 * 修改人：马腾<br>
	 * 修改时间：Nov 25, 2012 8:39:41 PM<br>
	 */
	public class DataGridColumnDateTime extends DataGridColumn {
		
		private var _dateFormat:String;
		
		public function DataGridColumnDateTime(columnName:String=null) {
			super(columnName);
		}
		
		override public function get labelFunction():Function{
			return dateFormatFunc;
		}
		
		private function dateFormatFunc(item:Object,column:DataGridColumn):String{
			if(this.dataField == null) return "";
			var date:Date = item[this.dataField] as Date;
			if(dateFormat == null || dateFormat == ""){
				return DateUtils.dateToString(date, DateUtils.CHINESE_ALL_DATE_FORMAT);
			}else{
				return DateUtils.dateToString(date, dateFormat);			
			}
		}
		
		public function get dateFormat():String {
			return _dateFormat;
		}
		
		public function set dateFormat(value:String):void {
			_dateFormat = value;
		}
	}
}